1
|
|
|
const {textFrom, textTo} = require('./textSnip.js') |
2
|
|
|
const {json, jsonPrettify, jsonEllipsify, jsonSnippet, jsonDelKeys} = require('./jsonSnip.js') |
3
|
|
|
|
4
|
|
|
export function runOption (option, args, inpObj) { |
5
|
|
|
// option is a string eg. '-jsonEllipsify' |
6
|
|
|
// arguments is an array of arguments for the option |
7
|
|
|
// inpObj is an object containing the text, type and json object we need to modify |
8
|
|
|
// this function acts as a marsheller to identify options and process them accordingly |
9
|
|
|
let funcs = { |
10
|
|
|
'--json': () => { json(inpObj) }, |
11
|
|
|
'--prettify': () => { jsonPrettify(inpObj, args) }, |
12
|
|
|
'--ellipsify': () => { jsonEllipsify(inpObj, args) }, |
13
|
|
|
'--snip': () => { jsonSnippet(inpObj, args) }, |
14
|
|
|
'--delKeys': () => { jsonDelKeys(inpObj, args) }, |
15
|
|
|
'--from': () => { textFrom(inpObj, args, false) }, |
16
|
|
|
'--start': () => { textFrom(inpObj, args, true) }, |
17
|
|
|
'--to': () => { textTo(inpObj, args, false) }, |
18
|
|
|
'--finish': () => { textTo(inpObj, args, true) } |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
if (funcs[option]) { |
22
|
|
|
funcs[option]() |
23
|
|
|
} else { |
24
|
|
|
inpObj.error.push("invalid option '" + option + "' for fsnip") |
25
|
|
|
} |
26
|
|
|
} |
27
|
|
|
|